/**
 * @program: yygh_parent
 * @ClassName UserHospitalController
 * @description:
 * @author: zyw
 * @create: 2023-05-30 17:05
 * @Version 1.0
 **/
package com.atguigu.yygh.hosp.controller.user;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(value = "医院显示接口")
@RequestMapping(value = "/user/hosp/hospital")
public class UserHospitalController {

    @Autowired
    private HospitalService hospitalService;

    @GetMapping("/list")
    @ApiOperation(value = "医院首页展示")
    public R getHospitalList(HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> pageModel = hospitalService.getHospitalPage(1, 10000, hospitalQueryVo);
        return R.ok().data("list", pageModel.getContent());
    }

    @GetMapping("/findByHosname/{hosname}")
    @ApiOperation(value = "根据医院名称进行模糊查询")
    public R findByHosname(@PathVariable String hosname) {
        List<Hospital> list = hospitalService.findByHosname(hosname);
        return R.ok().data("list", list);
    }

    @GetMapping("/detail/{hoscode}")
    @ApiOperation(value = "进到某个具体医院下的详情页面")
    public R getHospitalDetail(@PathVariable String hoscode) {
        Hospital hospital = hospitalService.getHospitalByHoscode(hoscode);
        return R.ok().data("hospital", hospital);
    }
}
 
